package com.jiyun.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jiyun.common.result.Result;
import com.jiyun.model.pojo.Coupon;
import com.jiyun.model.pojo.SpaInfo;
import com.jiyun.model.query.CouponQuery;
import com.jiyun.model.query.SpaInfoQuery;
import com.jiyun.service.SpaInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("admin/spa")
public class SpaInfoController {

    @Autowired
    private SpaInfoService spaInfoService;

    @GetMapping("/findPage")
    public List<SpaInfo> findPage(){
        return spaInfoService.list();
    }
    /**
     * 分页查询
     *
     * @param page  页码
     * @param limit 每页条数
     * @return 分页数据
     */
    @GetMapping("/{page}/{limit}")
    @ApiOperation("获取所有")
    public Result getPageList(@PathVariable Integer page, @PathVariable Integer limit, SpaInfoQuery query) {
        //封装分页参数
        query.setCurrentPage(page);
        query.setPageSize(limit);
        //查询分页数据
        IPage<SpaInfo> pageList = spaInfoService.getPageList(query);
        return Result.ok(pageList);
    }
}
